package com.bhs.sansonglogistics.ui.adapter;

import android.graphics.Color;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.bean.VoucherListBean;
import com.bhs.sansonglogistics.utils.DateUtils;
import com.bhs.sansonglogistics.utils.MyUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public class TopUpAdapter extends BaseQuickAdapter<VoucherListBean.DataDTO.ListDTO, BaseViewHolder> {

    public TopUpAdapter() {
        super(R.layout.item_voucher);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, VoucherListBean.DataDTO.ListDTO item) {
        helper.setText(R.id.tv_line_name, item.getLine_name());
        helper.setText(R.id.tv_status, MyUtils.refundStatus(item.getRefund_status()));
        helper.setText(R.id.tv_money, String.format("￥%s", !TextUtils.isEmpty(item.getMoney()) ? item.getMoney() : item.getPay_money()));
        helper.setTextColor(R.id.tv_money, Color.parseColor("#485EF4"));
        helper.setText(R.id.tv_type, MyUtils.getPayType(item.getPay_method()));
        helper.setText(R.id.tv_number, item.getOrder_sn());
        helper.setText(R.id.tv_voucher_time, DateUtils.getTime2(item.getPay_time()));
        helper.setText(R.id.tv_refund_time, DateUtils.getTime2(item.getRefund_time()));
        helper.setGone(R.id.ll_refund_time, item.getRefund_time() > 0);
        helper.setGone(R.id.ll_type_withdrawal, item.getPay_time() > 0);
        helper.setGone(R.id.ll_surplus_time, item.getMember_end_time() > 0);
        helper.setText(R.id.tv_surplus_time,MyUtils.getDayHour(item.getMember_end_time()));
    }
}
